package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.ExpTutor;
import com.ruoyi.system.service.IExpTutorService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 导师管理Controller
 * 
 * @author ruoyi
 * @date 2023-06-20
 */
@RestController
@RequestMapping("/system/tutor")
public class ExpTutorController extends BaseController
{
    @Autowired
    private IExpTutorService expTutorService;

    /**
     * 查询导师管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:tutor:list')")
    @GetMapping("/list")
    public TableDataInfo list(ExpTutor expTutor)
    {
        startPage();
        List<ExpTutor> list = expTutorService.selectExpTutorList(expTutor);
        return getDataTable(list);
    }

    /**
     * 导出导师管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:tutor:export')")
    @Log(title = "导师管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ExpTutor expTutor)
    {
        List<ExpTutor> list = expTutorService.selectExpTutorList(expTutor);
        ExcelUtil<ExpTutor> util = new ExcelUtil<ExpTutor>(ExpTutor.class);
        util.exportExcel(response, list, "导师管理数据");
    }

    /**
     * 获取导师管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:tutor:query')")
    @GetMapping(value = "/{teaID}")
    public AjaxResult getInfo(@PathVariable("teaID") String teaID)
    {
        return success(expTutorService.selectExpTutorByTeaID(teaID));
    }

    /**
     * 新增导师管理
     */
    @PreAuthorize("@ss.hasPermi('system:tutor:add')")
    @Log(title = "导师管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ExpTutor expTutor)
    {
        return toAjax(expTutorService.insertExpTutor(expTutor));
    }

    /**
     * 修改导师管理
     */
    @PreAuthorize("@ss.hasPermi('system:tutor:edit')")
    @Log(title = "导师管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ExpTutor expTutor)
    {
        return toAjax(expTutorService.updateExpTutor(expTutor));
    }

    /**
     * 删除导师管理
     */
    @PreAuthorize("@ss.hasPermi('system:tutor:remove')")
    @Log(title = "导师管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{teaIDs}")
    public AjaxResult remove(@PathVariable String[] teaIDs)
    {
        return toAjax(expTutorService.deleteExpTutorByTeaIDs(teaIDs));
    }
}
